#ifndef RECVTABLEMODEL_H
#define RECVTABLEMODEL_H

#include <QAbstractTableModel>

class RecvTableModel : public QAbstractTableModel
{
    Q_OBJECT

public:

    explicit RecvTableModel(QObject *parent = nullptr);

    // Header:
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    //bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;

    // Basic functionality:
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    void setTableData(const QList<QStringList> &dataList);

    //删除一行商品信息
    QString removeCurrentRowData(int row = -1);
    //清除数据
    void clearData();
    //获取条码和编号
    QString getBarCode(int row = -1);
    QString getGoodId(int row = -1);
    //增加一行数据
    void insertOneRow(QStringList &infoList, QString barCode);
    //追加一行数据
    void appendRow(QStringList &infoList);//此list包含条码

    //获取一行数据信息
    QStringList getData(int row = -1);
    //更新一行数据
    bool updateOneRow(QStringList &infoList, QString barCode, int row = -1);
private:
    QStringList m_headList;  //表头
    QList<QStringList> m_dataList;
};

#endif // RECVTABLEMODEL_H
